//
// Project: Disagreement in science: Missing women



clear all
version 15.1  



//
// set locals

// method of identifying female variable
local female "female_genderize"

// gender of author is known
local known_gender "female_genderize!=."




//
// Biorxiv

// call data
use "${data}/output/biorxiv_gender.dta", clear


 
// analysis

// share of females in article
by article_id, sort: egen number_authors = count(article_id)
by article_id, sort: egen number_authors_female = total(`female'==1)
generate share_female = number_authors_female/number_authors

//
// all authors

// baseline
local i=1
local coefficients`i' "1 2"
regress share_female ib3.results_type_id if author_id==1, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)
contrast rb1.results_type_id, effects
matrix b`i' = r(table)

// subject FE
local i=2
local coefficients`i' "1 2"
regress share_female ib3.results_type_id i.subject_id if author_id==1, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)
margins results_type_id, pwcompare(pv)
contrast rb1.results_type_id, effects
matrix b`i' = r(table)

// subject and year FE
local i=3
local coefficients`i' "1 2"
regress share_female ib3.results_type_id i.subject_id i.year if author_id==1, vce(robust)
matrix m`i' = r(table)
scalar n`i' = e(N)
scalar rsq`i' = e(r2)
* p-vales
foreach k of numlist `coefficients`i'' {
	local p`i'_`k' = m`i'[4,`k']
}
margins results_type_id
matrix a`i' = r(b)
contrast rb1.results_type_id, effects
matrix b`i' = r(table)





//
// significance stars for regressions above
forvalues j=1/3 {
	foreach k of numlist `coefficients`j'' {
		if `p`j'_`k''<0.1 & `p`j'_`k''>=0.05 {
			scalar st`j'_`k'="*"
		}
		else if `p`j'_`k''<0.05 & `p`j'_`k''>=0.01 {
			scalar st`j'_`k'="**"
		}
		else if `p`j'_`k''<0.01 & `p`j'_`k''>=0.001 {
			scalar st`j'_`k'="***"
		}
		else if `p`j'_`k''<0.001 {
			scalar st`j'_`k'="****"
		}
		else {
			scalar st`j'_`k'=""
		}
	}
}
	




